package com.ruoyi.eam.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.eam.doman.DictData;
import com.ruoyi.eam.mapper.DictDataMapper;
import com.ruoyi.eam.service.IDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 字典数据Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-18
 */
@Service
public class DictDataServiceImpl implements IDictDataService
{
    @Autowired
    private DictDataMapper dictDataMapper;

    /**
     * 查询字典数据
     *
     * @param dictCode 字典数据主键
     * @return 字典数据
     */
    @Override
    public DictData selectDictDataByDictCode(Long dictCode)
    {
        return dictDataMapper.selectDictDataByDictCode(dictCode);
    }

    /**
     * 查询字典数据列表
     *
     * @param dictData 字典数据
     * @return 字典数据
     */
    @Override
    public List<DictData> selectDictDataList(DictData dictData)
    {
        return dictDataMapper.selectDictDataList(dictData);
    }

    /**
     * 新增字典数据
     *
     * @param dictData 字典数据
     * @return 结果
     */
    @Override
    public int insertDictData(DictData dictData)
    {
        dictData.setCreateTime(DateUtils.getNowDate());
        return dictDataMapper.insertDictData(dictData);
    }

    /**
     * 修改字典数据
     *
     * @param dictData 字典数据
     * @return 结果
     */
    @Override
    public int updateDictData(DictData dictData)
    {
        dictData.setUpdateTime(DateUtils.getNowDate());
        return dictDataMapper.updateDictData(dictData);
    }

    /**
     * 批量删除字典数据
     *
     * @param dictCodes 需要删除的字典数据主键
     * @return 结果
     */
    @Override
    public int deleteDictDataByDictCodes(Long[] dictCodes)
    {
        return dictDataMapper.deleteDictDataByDictCodes(dictCodes);
    }

    /**
     * 删除字典数据信息
     *
     * @param dictCode 字典数据主键
     * @return 结果
     */
    @Override
    public int deleteDictDataByDictCode(Long dictCode)
    {
        return dictDataMapper.deleteDictDataByDictCode(dictCode);
    }
}
